package com.vcc.boss.core.queue.transaction.model;


import lombok.Data;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

@Data
public class RiskUserCardQueueDto implements Delayed {

    private Long userCardId;

    private Long time;

    @Override
    public long getDelay(@NotNull TimeUnit unit) {
        return unit.convert(time - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
    }

    @Override
    public int compareTo(@NotNull Delayed o) {
        return Long.compare(getDelay(TimeUnit.MILLISECONDS), o.getDelay(TimeUnit.MILLISECONDS));
    }

    public RiskUserCardQueueDto(Long userCardId, Long time) {
        this.userCardId = userCardId;
        this.time = time;
    }
}
